<%--
  Created by IntelliJ IDEA.
  User: LiuXiaoChuan
  Date: 2022/5/9
  Time: 16:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>查询列表</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ajaxForm.js"></script>
    <script>
        layui.use(['table','util','jquery','layer','form'],function () {
            var table = layui.table,ut=layui.util,$=layui.jquery,layer=layui.layer,form=layui.form;

            //转载table
            var tabStaff= table.render({
                elem:'#tableData',//指定id选择器
                cols:[[
                    {field:'feedbackId',title:'编号'},
                    {field:'feedBackType',title:'职务',templet:function (d) {
                            var pid=d.feedBackType;
                            if (pid==1){
                                return "员工";
                            }else if (pid==2){
                                return "学生";
                            }
                        }},
                    // {field:'empId',title:'员工编号'},
                    {field:'empName',title:'姓名'},
                    {field:'feedbackTime',title:'反馈时间',templet:function(d){return ut.toDateString(d.feedbackTime,'yyyy年MM月dd日')}},
                    {field:'remark',title:'建议'},
                    {field:'image',title:'图片'},
                    {field:'status',title:'状态',templet:function (d) {
                            var pid=d.status;
                            if (pid==1){
                                return "未处理";
                            }else if (pid==2){
                                return "已处理";
                            }
                        }},
                    {field:'depName',title:'反馈部门'},

                    {field:'opinion',title:'审批意见'},
                    {field:'userId',title:'审批人'},
                    {field:'replyTime',title:'回复时间',templet:function(d){return ut.toDateString(d.replyTime,'yyyy年MM月dd日')}},
                    {toolbar:'#tools',title:'操作',width:180,align:'center',fixed:'right'}
                ]],
                url:'${pageContext.request.contextPath}/make/fklist',//请求路径

                method:'post',//请求方法
                page:true,//显示分页
                limits:[10,20,30,40,50],//切换的每页行数
                limit:10,//默认的每页行数
                loading:true,//数据加载效果样式
                done:function (res,curr,count) {//表格数据渲染完后的回调方法(res 整个table的内容 curr 当前页 count 总行数)
                   var dd = res.data;//取出列表数据(对象数组)
                   // alert(dd[0].sname+""+curr+""+count);
                    $("[data-field='positions_id']").children().each(function () { //获取页面的所有职位id并循环
                        var pid = $(this).text(); //取出每一个数据
                        if (pid==1){
                            $(this).text("员工");
                        }else if(pid==2){
                            $(this).text("学生");
                        }
                    });
                },
                done:function (res,curr,count) {//表格数据渲染完后的回调方法(res 整个table的内容 curr 当前页 count 总行数)
                    var dd = res.data;//取出列表数据(对象数组)
                    // alert(dd[0].sname+""+curr+""+count);
                    $("[data-field='positions_id']").children().each(function () { //获取页面的所有职位id并循环
                        var pid = $(this).text(); //取出每一个数据
                        if (pid==1){
                            $(this).text("未处理");
                        }else if(pid==2){
                            $(this).text("已处理");
                        }
                    });
                }
            });

            //监听form表单提交  模糊查询  查看全部按钮
            form.on('submit(shuax-btn)',function (d) {
                location.reload("titleEt");//重新加载父页面表格
            });

            //监听form表单提交
            form.on('submit(search-btn)',function (d) {
                var sid=  $("#feedbackId").val();
                var ename=$("#empName").val();
                 // alert(sid+""+ename);
                table.reload("tableData",{ //指定条件重载table
                    page:{curr:1},
                    where:{ //条件
                        feedbackId:sid,
                        empName:ename

                    }
                });
            });
            form.verify({
                num_sz:[
                    /(^$)|^\d+$/,
                    '只能填写数字'
                ],
            });
            //监听工具栏的按钮
            table.on('tool(demo)',function (res) {
                var row = res.data; //获取当前数据（点哪一行就是哪一行）
                var event = res.event;//获取点的是哪个按钮

                var feedbackId = row.feedbackId;
                // alert(feedbackId);
                if(event=='cha'){//如果是修改
                    layer.open({
                        type:2,
                        fix:false,
                        maxmin:true,
                        offset:'10px',
                        shadeClose:true,
                        shade:0.4,
                        area:['600px','520px'],
                        title:"查看反馈问题",
                        content:'${pageContext.request.contextPath}/make/chayue/'+feedbackId
                    });
                } else if (event=='xg') {
                    layer.open({
                        type:2,
                        fix:false,
                        maxmin:true,
                        offset:'10px',
                        shadeClose:true,
                        shade:0.4,
                        area:['600px','520px'],
                        content:'${pageContext.request.contextPath}/make/sp/'+feedbackId
                    });
                }
            });
            //监听添加按钮
            $("#add-btn").click(function () {
                layer.open({
                    type:2,//设置为iftame
                    fix:false,//不固定
                    maxmin:true,//出现最大化最小化按钮
                    offset:'5px',//垂直水平位置
                    shadeClose:true,//点击遮罩层关闭窗口
                    shade:0.4,//遮罩层透明度
                    area:['600px','520px'],//弹出层宽度高度
                    title:'新增',//弹出层标题
                    content: '${pageContext.request.contextPath}/make/toadd' //弹出层内网页
                });
            });
        });
    </script>
</head>
<body>
<div>
    <form class="layui-form">
        <div class="layui-inline">编号</div>
        <div class="layui-inline">
            <input type="text" name="sid" id="feedbackId" class="layui-input" lay-verify="num_sz"/>
        </div>
        <div class="layui-inline">姓名</div>
        <div class="layui-inline">
            <input type="text" name="ename" id="empName" class="layui-input"/>
        </div>
        <a class="layui-btn layui-icon layui-icon-search" lay-filter="search-btn"  lay-size="sm">搜索</a>
        <a class="layui-btn layui-icon layui-icon-refresh" lay-filter="shuax-btn"  lay-size="sm">刷新</a>
        <a class="layui-btn layui-icon layui-icon-add-1" id="add-btn"   lay-size="sm">添加</a>
    </form>
</div>
<table class="layui-table" id="tableData" lay-filter="demo" ></table>
<!--定义工具栏-->
<script type="text/html" id="tools">
    <a class="layui-btn layui-btn-sm layui-icon layui-icon-edit" lay-event="xg">审批</a>
    <a class="layui-btn layui-btn-sm layui-icon layui-icon-tree" lay-event="cha">查阅</a>
</script>
</body>
</html>
